<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
       $this->display();
    }
    public function upload(){
		$upload = new \Think\Upload();// 实例化上传类
	    $upload->maxSize   =     3145728 ;// 设置附件上传大小
	    $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
	    $upload->rootPath  =     './Public/uploads/photo/'; // 设置附件上传根目录
	   
	   	$upload->autoSub=false;
	    $info= $upload->upload();  // 上传文件 
	    var_dump ($info);
	    return $info;    
	}
	public function userReg(){
		

		$user=D("Users");
		if($user->create()){
		
		if($_FILE['photo']['error']==0){
			$photoinfo=$this->upload();
			$user->photo=$photoinfo['photo']['savename'];
		}else{
			$user->photo='defolse.jpg';
		}
		$user->verifyinfo="待审核";
		
		if ($user->add()) {
				 $this->success('添加成功','../../Admin/Index/users',4);
		} else{
				
				$this->error("添加失败");
		}
	}else{
          $this->error($user->getError());  
     }  
}
}